package com.sunfeng.n6;

import java.math.BigDecimal;

/**
 * @author sunfeng  不安全的实现
 * @date 2021/04/14 13:35
 **/
public class DecimalAccountUnsafe implements DecimalAccount {

    BigDecimal balance;

    public DecimalAccountUnsafe(BigDecimal balance) {
        this.balance = balance;
    }

    @Override
    public BigDecimal getBalance() {
        return balance;
    }

    @Override
    public void withdraw(BigDecimal amount) {
        BigDecimal balance = this.getBalance();
       this.balance = balance.subtract(amount);
    }
}
